package com.mooc.yohoshop.dao;

import android.database.sqlite.SQLiteDatabase;
import com.mooc.yohoshop.App;

public class DaoDBUtils {

    private DaoDBUtils(){
        init();
    }

    private static DaoDBUtils instance;

    public static DaoDBUtils getInstance() {
        if (instance == null)
            instance = new DaoDBUtils();
        return instance;
    }

    private DaoSession daoSession;
    private SQLiteDatabase database;
    private DaoMaster master;
    public void init(){
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(
                App.getInstance().getApplicationContext(),"catch.db");
        database = helper.getWritableDatabase();
        master = new DaoMaster(database);
        daoSession = master.newSession();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}
